module.exports = function (success,error) {

    const mongoose = require('mongoose')

    const {DB_URL,DB_PORT,DB_DATABASE} = require('./options')
    
    mongoose.connect(`mongodb://${DB_URL}:${DB_PORT}/${DB_DATABASE}`)

    mongoose.connection.once('open',() => { 
        success()
    })

    mongoose.connection.on('error',() => { 
        error()
    })

    mongoose.connection.on('close',() => { 
        console.log('关闭连接')
    })

}
